package com.cloud.system.interfaces;

import com.cloud.system.common.config.FeignConfiguration;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * @program: quokka-server
 * @description: ${description}
 * @author: sl
 * @create: 2019-07-04 15:49
 **/
@FeignClient(value = "FORCE", configuration = FeignConfiguration.class, fallbackFactory = FeignClientForceFallbackFactory.class)
public interface FeignClientForce {

    /**
     * 首页 行政强制
     * @return
     */
    @RequestMapping(value = "force/interface/getLawDynamicsInfo", method = RequestMethod.GET)
    Map<String,Object> getLawDynamicsInfo(@RequestParam("unitCode") String unitCode);
    /**
     *获取案卷号
     */
    @RequestMapping(value = "force/interface/calculate", method = RequestMethod.GET)
    String calculate(@RequestParam("recTypeId") String recTypeId);
}

@Component
class FeignClientForceFallbackFactory implements FallbackFactory<FeignClientForce> {
    private static final Logger LOGGER = LoggerFactory.getLogger(FeignClientForceFallbackFactory.class);

    @Override
    public FeignClientForce create(final Throwable cause) {
        return new FeignClientForce() {
            @Override
            public Map<String, Object> getLawDynamicsInfo(String unitCode) {
                return null;
            }
            @Override
            public String calculate(String recTypeId){
                return "-1";
            }
        };
    }

}
